<html>
<head>
    <meta charset="UTF-8">
    <title>应用模型信息列表</title>
    <link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
    <link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
    <script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
    <script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
    <script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
    <script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
    <script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
    <script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
    <script src="../../ffres/dict/all.js" type="text/javascript"></script>
    <link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>
    <a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<script type="text/javascript">
    var appId = $.getUrlParam('appId');
    var projectId = $.getUrlParam('projectId');
    var appModelCatalog = 'A01'; //$.getUrlParam('appModelCatalog');
    var packageId = $.getUrlParam('packageId');
    var packageCode = $.getUrlParam('packageCode');

    function doAdd() {
        JLEUtil.createModalWin('新增', `AppModelInfoAdd.html?appId=${appId}&projectId=${projectId}&appModelCatalog=A01&packageCode=${packageCode}`);
    }

    function doUpdate() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            if (row.appModelCatalog == 'A01') {
                // 外部服务
                // var url = `AppModelInfoUpdateNewTab.html?appId=${appId}` + '&appModelId=' + row.appModelId;
                var url = `AppModelInfoUpdateNewTable.html?appId=${appId}` + '&appModelId=' + row.appModelId;
                var title = `${row.appModelCode}-${row.appModelName}修改`;
                // window.parent.addTab(title, url);
                JLUtil.linkNewPage(url);
            } else {
                // JLEUtil.createModalWin('编辑',`AppModelInfoUpdate.html?appId=${appId}` + '&appModelId=' + row.appModelId );
            }
        } else {
            $.messager.alert('提示', '请选择一条记录！', 'info');
        }
    }

    function doDelete() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('删除提示', '你确定要删除这条记录?', function (r) {
                if (r) {
                    var jsonData = {
                        appModelId: row.appModelId,
                        appId: appId
                    };
                    $.restfulDelete('../../api/app/model/info', jsonData, function (
                        data) {
                        $.messager.alert('提示', '记录删除成功!', 'info');
                        $('#dg').datagrid('reload');
                    });
                }
            });
        } else {
            $.messager.alert('提示', '请选择一条记录！', 'info');
        }
    }

    function doView() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            if (row.appModelCatalog == 'A01') {
                // 外部服务
                var url = `AppModelInfoView-A01.html?appId=${appId}` + '&appModelId=' + row.appModelId;
                var title = `${row.appModelCode}-${row.appModelName}`;
                // window.parent.addTab(title, url);
                JLUtil.linkNewPage(url);
            } else{
                JLEUtil.createModalWin('详情',`AppModelInfoView.html?appId=${appId}` + '&appModelId=' + row.appModelId );
            }
        } else {
            $.messager.alert('提示', '请选择一条记录！', 'info');
        }
    }

    function reloadList() {
        $('#dg').datagrid('reload');
        JLEUtil.closewin();
    };
    $(function () {
        $('#dg').datagrid({
            url: '../../api/app/model/infos?appId=' + appId,
            queryParams:{
                'packageId':packageId, 
                'appModelCatalog':appModelCatalog,
                'tableModelCode': packageCode
                }
        });
    });
</script>
</head>

<body class="easyui-layout">
    <div data-options="region:'north',title:''" class="divSearchBar">
        <form id="searchForm">
            <table>
                <tr>
                    <td>&nbsp;外部服务模型代码：</td>
                    <td><input name="appModelCode" id="appModelCode" /></td>
                    <td>&nbsp;外部服务模型名称：</td>
                    <td><input name="appModelName" id="appModelName" /></td>
                    <td><a class="easyui-linkbutton" href="javascript:void(0);"
                            onclick="JLEUtil.queryForm('searchForm','dg','../../api/app/model/infos?appId='+appId);">查找</a>
                    </td>
                    <td><a class="easyui-linkbutton" href="javascript:void(0);"
                            onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
                </tr>
            </table>
        </form>
    </div>
    <div data-options="region:'center',split:false">
        <table id="dg" class="easyui-datagrid" title="" style="width:100%;height:100%"
            data-options="singleSelect:true,collapsible:true,method:'post'" toolbar="#tb" title="Load Data"
            rownumbers="true" pagination="true" pageSize="20">
            <thead>
                <tr>
                    <th data-options="field:'appModelId',resizable:true" hidden="true">外部服务模型标识</th>
                    <th data-options="field:'appModelCode',resizable:true">外部服务标识</th>
                    <th data-options="field:'appModelName',resizable:true">外部服务模型名称</th>
                    <th data-options="field:'appModelCatalog',resizable:true" formatter="formatter_APP_MODEL_CATALOG" hidden="true">外部服务模型分类</th>
                    <th data-options="field:'appModelType',resizable:true" formatter="formatter_APP_MODEL_TYPE">外部服务模型类型</th>
                    <th data-options="field:'packageId',resizable:true" hidden="true">目录包标识</th>
                    <th data-options="field:'tableModelId',resizable:true" hidden="true">表模型ID</th>
                    <th data-options="field:'tableModelCode',resizable:true">表模型代码</th>
                    <th data-options="field:'tableModelName',resizable:true">表模型名称</th>
                    <!-- <th data-options="field:'createUser',resizable:true">创建人</th>
                    <th data-options="field:'createTime',resizable:true">创建时间</th>
                    <th data-options="field:'lastUpdateUser',resizable:true">最后修改人</th>
                    <th data-options="field:'lastUpdateTime',resizable:true">最后更新时间</th> -->
                </tr>
            </thead>
        </table>
    </div>
    <div id="tb" style="padding:1px">
        <div style="margin-bottom:2px">
            <a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true">创建外部服务模型</a>
            <a href="javascript:doUpdate()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">编辑外部服务模型</a>
            <a href="javascript:doDelete()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除外部服务模型</a>
            <a href="javascript:doView()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">查看外部服务模型</a>
        </div>
    </div>
</body>

</html>